package dk.eclipse.android.helpers;

import android.content.Context;
import android.net.Uri;
import android.widget.MediaController;
import android.widget.VideoView;

public class VideoHelper {

	/**
	 * Plays a video.
	 * 
	 * @param context
	 * @param path
	 * @param fileName
	 * @param autoplay
	 */
	public void videoPlayer(Context context, String path, String fileName,
			boolean autoplay) {

		// the VideoView will hold the video
		VideoView videoHolder = new VideoView(context);

		// MediaController is the ui control howering above the video (just like
		// in the default youtube player).
		videoHolder.setMediaController(new MediaController(context));

		// assing a video file to the video holder
		videoHolder.setVideoURI(Uri.parse(path + "/" + fileName));

		// get focus, before playing the video.
		videoHolder.requestFocus();

		if (autoplay) {
			videoHolder.start();
		}

	}

}
